package com.schoolcloud.front.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.schoolcloud.common.util.UserContext;
import com.schoolcloud.front.entity.UserFollow;
import com.schoolcloud.front.service.UserFollowService;
import com.schoolcloud.front.mapper.UserFollowMapper;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;

/**
* @author hongmizfb
* @description 针对表【user_follow(用户关注关系表)】的数据库操作Service实现
* @createDate 2025-08-05 16:12:31
*/
@Service
public class UserFollowServiceImpl extends ServiceImpl<UserFollowMapper, UserFollow>
    implements UserFollowService{

    @Override
    public void saveUserFollow(UserFollow userFollow) {
        userFollow.setCreateTime(LocalDateTime.now());
        System.out.println("打印"+UserContext.getUserIdToLong());
        userFollow.setFollowerId(UserContext.getUserIdToLong());
        save(userFollow);
    }

    @Override
    public Boolean chexkIsFollow(Integer userId) {
        return lambdaQuery().eq(UserFollow::getFollowerId, UserContext.getUserIdToLong())
                .eq(UserFollow::getFollowingId, userId).exists();
    }
}




